package com.atcumt.alibaba;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

/* 
 * 4
 * 123 45 678 23
 * 
 * 67845123
 */
public class WZ01 {
    
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // String[] strs = in.nextLine().split(" ");
        
        int n = in.nextInt();
        // long[] nums = new long[n];
        List<String> numsList = new ArrayList<>();
        List<String> resList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            numsList.add(String.valueOf(in.nextInt()));
        }
        Collections.sort(numsList, new Comparator<String>() {

            @Override
            public int compare(String o1, String o2) {
                // TODO Auto-generated method stub
                if (o1.length() == o2.length()) {
                    return Integer.valueOf(o2) - Integer.valueOf(o1);
                } else {
                    return o2.length() - o1.length();
                }
            }
        });

        for (int i = 0; i < 3; i++) {
            resList.add(numsList.get(i));
        }
        Collections.sort(resList, new Comparator<String>() {

            @Override
            public int compare(String o1, String o2) {
                // TODO Auto-generated method stub
                if (o1.length() == o2.length()) {
                    return Integer.valueOf(o2) - Integer.valueOf(o1);
                } else {
                    return Integer.valueOf(o2.charAt(0)) - Integer.valueOf(o1.charAt(0));
                }
            }
        });
        String ans = resList.get(0) + resList.get(1) + resList.get(2);
        System.out.println(ans);
        in.close();
    }
}
